<template>
    <vxe-modal
        class-name="rk-modal proj-review-info"
        :loading="loading"
        resize
        transfer
        show-zoom
        fullscreen
        destroyOnClose
        v-model="visible"
        width="90%"
        height="90%"
        :z-index="1002"
        min-width="460"
        min-height="320"
        @close="handleClose"
    >
        <template #title>
            <div w-xs>项目评审详情：{{ localData.proName }}</div>
        </template>
        <template #default>
            <el-tabs class="proj-review-info-tabs" v-model="activeName">
                <el-tab-pane v-for="(item,index) in sources" :label="`${item.taskName}`" :name="`tab_${index}`">
                    <ReviewReportComponents :config="item.config"/>
                </el-tab-pane>
            </el-tabs>
        </template>
    </vxe-modal>
</template>
<script setup>

import {onMounted, ref} from "vue";
// import ReviewReportDrawer from "@/views/project/bond/drawer/ReviewReportDrawer.vue";
import ReviewReportComponents from "@/views/project/bond/drawer/ReviewReportComponents.vue";
import { useExpertsApi } from '@/api/index'
const { getTaskInfoByApplyId } = useExpertsApi();
const visible = ref(false)
// 是否加载中
const loading = ref(true)
const localData = ref({})

const activeName = ref('tab_0')

const sources = ref([])

const handleOpen = async (config) => {
    localData.value = config
    const {applyId} = config
    let resp = await getTaskInfoByApplyId(applyId);
    if (resp.code === 200) {
        let datas = []
        if (resp.data) {
            for (let item of resp.data) {
                let temp = Object.assign({}, {taskName: item.taskName},
                    {config: {taskId: item.taskId, applyId}});
                datas.push(temp)
            }
        }
        sources.value = datas
    }
    // console.log(sources);
    visible.value = true
}

const handleClose = () => {
    handleReset()
}
/**
 * 重置数据
 */
const handleReset = () => {
    visible.value = false
    loading.value = false
}
onMounted(() => {
    loading.value = false
})

// 对外暴露方法
defineExpose({
    handleOpen
})
</script>
<style lang="scss" scoped>
.proj-review-info-tabs {
    height: 100%;
    display: flex;
    flex-direction: column;
    :deep(.el-tabs__nav-wrap) {
        padding: 0 8px
    }
    :deep(.el-tabs__header) {
        margin: 0;
    }
    :deep(.el-tabs__content) {
        flex: 1;
        padding: 8px;
    }
    :deep(.el-tab-pane) {
        height: 100%;
    }
}
</style>
<style lang="scss">
.proj-review-info {
    .vxe-modal--content {
        padding: 0
    }
}
</style>
